package linkedList;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;

public class TestLinkedList {
    public static void main1(String[] args) {
        //链表的遍历
        LinkedList<Integer> list = new LinkedList<>();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);
        System.out.println("============1===========");
        System.out.println(list);
        System.out.println("============2===========");
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
        System.out.println("============3===========");
        for(int x : list) {
            System.out.print(x + " ");
        }
        System.out.println();
        System.out.println("============4===========");
        //迭代器
        Iterator<Integer> it = list.iterator();
        while(it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();
        ListIterator<Integer> it1 = list.listIterator(list.size());
        while(it1.hasPrevious()) {
            System.out.print(it1.previous() + " ");
        }
        System.out.println();
        System.out.println("============4===========");

    }

    public static void main2(String[] args) {
        LinkedList<Integer> list = new LinkedList<>();
        list.addLast(1);
        list.addLast(2);
        list.addLast(3);
        list.addLast(4);


    }

    public static void main(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
//        MyLinkedList.addLast(4);
    }
}
